package main.剑指OfferⅠ;

public class Day21 {
    public static void main(String[] args) {
        System.out.println("剑指Offer15.二进制中1的个数");
        System.out.println("剑指Offer65.数值的整数次方");
    }
}

class Offer15{
    public int hammingWeight(int n) {
        int count=0;
        for (int i=0;i<32;i++){
            if (((n>>i)&1)==1) count++;
        }
        return count;
    }
}

class Offer65{
    public int add(int a, int b) {
//        while (b != 0) {
//            int carry = (a & b) << 1;
//            a = a ^ b;
//            b = carry;
//        }
//        return a;
        return Math.addExact(a,b);
    }
}